package com.example.jobback.controller.manager;

import com.example.jobback.resp.manager.employee.page.recruiter.MCrossGetPageRecruitersResp;
import com.example.jobback.resp.manager.position.GetPositionMessageResp;
import com.example.jobback.resp.manager.position.page.MCrossGetPagePositionsResp;
import com.example.jobback.resp.manager.position.publish.ManagerPendingPubJobResp;
import com.example.jobback.resp.manager.position.update.ManagerPendingUpdateJobResp;
import com.example.jobback.result.Result;
import com.example.jobback.service.manager.ManagerPositionService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName: ManagerPositionController
 * @Description:管理员-岗位管理控制器
 * @Author: lhb
 * @Date: 2025/6/21
 */
@RestController
@RequestMapping("/manager/position")
@Tag(name = "管理员-岗位管理控制器",description = "管理员岗位管理服务的相关接口")
public class ManagerPositionController {

    private final ManagerPositionService managerPositionService;

    public ManagerPositionController(ManagerPositionService managerPositionService) {
        this.managerPositionService = managerPositionService;
    }


    @Operation(summary = "获取发布待审核岗位的列表",description = "目前为全量查询，后期改为分页查询")
    @GetMapping("/getPublishPositionLists")
    @ApiResponse(description = "返回待审核岗位响应体列表")
    public Result<List<ManagerPendingPubJobResp>> getPublishPositionLists(){
        return managerPositionService.getPublishPositionLists();
    }




    @Operation(summary = "审核发布岗位不通过",description = "无")
    @PostMapping("/verifyPublishPositionFailed")
    @ApiResponse(description = "返回token，延时登录态")
    public Result<Object> verifyPublishPositionFailed(@Parameter(description = "唯一标识", required = true)
                                                      @RequestParam String code,
                                                      @Parameter(description = "原因填写", required = true)
                                                      @RequestParam String failMessage){
        return managerPositionService.verifyPublishPositionFailed(code,failMessage);
    }


    @Operation(summary = "审核发布岗位通过",description = "无")
    @PostMapping("/verifyPublishPosition")
    @ApiResponse(description = "返回token，延时登录态")
    public Result<Object> verifyPublishPosition(@Parameter(description = "唯一标识", required = true)
                                                @RequestParam String code) {
        return managerPositionService.verifyPublishPosition(code);
    }

    @Operation(summary = "获取变更待审核岗位的列表",description = "目前为全量查询，后期改为分页查询")
    @GetMapping("/getUpdatedPositionLists")
    @ApiResponse(description = "返回变更待审核岗位的列表")
    public Result<List<ManagerPendingUpdateJobResp>> getUpdatedPositionLists(){
        return managerPositionService.getUpdatedPositionLists();
    }


    @Operation(summary = "审核岗位变更通过",description = "无")
    @PostMapping("/VerifyChangePosition")
    @ApiResponse(description = "返回token，延时登录态")
    public Result<Object> VerifyChangePosition(@Parameter(description = "职位id", required = true)
                                               @RequestParam Long positionId) {
        return managerPositionService.VerifyChangePosition(positionId);
    }


    @Operation(summary = "审核岗位变更不通过",description = "无")
    @PostMapping("/VerifyChangePositionFailed")
    @ApiResponse(description = "返回token，延时登录态")
    public Result<Object> VerifyChangePositionFailed(@Parameter(description = "职位id", required = true)
                                                     @RequestParam Long positionId,
                                                     @Parameter(description = "错误反馈信息", required = true)
                                                     @RequestParam String failedMessage) {
        return managerPositionService.VerifyChangePositionFailed(positionId,failedMessage);
    }

    @Operation(summary = "分页查询职位列表",description = "跨服务调用，调用方")
    @ApiResponse(description = "无")
    @GetMapping("/getPositions")
    public Result<MCrossGetPagePositionsResp> getPositions(@Parameter(description = "页码", required = true)@RequestParam int page,
                                                           @Parameter(description = "每页的数量", required = true)@RequestParam int size,
                                                           @Parameter(description = "搜索内容", required = true)@RequestParam String content){
        return managerPositionService.getPositions(page,size,content);
    }


    @Operation(summary = "查看职位详细",description = "跨服务调用，调用方")
    @ApiResponse(description = "无")
    @GetMapping("/getPositionMessage")
    public Result<GetPositionMessageResp> getPositionMessage(@Parameter(description = "职位id", required = true)
                                                                     @RequestParam Long positionId
                                                           ){
        return managerPositionService.getPositionMessage(positionId);
    }



}
